exports.clone = function (target, filterFun) {
  let tempData = {}
  for (let key in target) {
    if (target.hasOwnProperty(key) && filterFun ? filterFun(key, target) : true) {
      tempData[key] = target[key]
    }
  }
  return tempData
}
exports.merge = function (target, value) {
  let tempData = {}
  for (let key in target) {
    if (target.hasOwnProperty(key)) {
      tempData[key] = target[key]
    }
  }
  for (let key in value) {
    if (value.hasOwnProperty(key)) {
      tempData[key] = value[key]
    }
  }
  return tempData
}

function getTag (obj) {
  if (obj === null) {
    return obj + ''
  }
  return typeof obj === 'object' || typeof obj === 'function'
    ? obj.constructor.name.toLowerCase() || 'object'
    : typeof obj
}
function isEmpty (value) {
  let empty = false
  if (value) {
    let type = getTag(value)
    switch (type) {
      case 'string': {
        empty = value.trim() === ''
        break
      }
      case 'array': {
        empty = !value.length
        break
      }
      case 'object': {
        empty = !Object.keys(value).length
        break
      }
      default: {
        break
      }
    }
  } else {
    empty = value === '' || isNaN(value) || value === undefined || value === null
  }
  return empty
}
// '',' ',NaN,undefined,null,[],{}
exports.isEmpty = isEmpty
